<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 12px;
}
</style>
</head>
<body class="gray-bg">

	<!-- 隐藏域 -->
	<input type="hidden" value="${replaceId}" id="replaceId" name="replaceId" />
	<input type="hidden" value="${busiId}"    id="busiId" name="busiId" />
	<input type="hidden" value="${modeId}"    id="modeId" name="modeId" />
	<!-- 隐藏域 -->

	<div class="container creditbody">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;垫款调整B</span>
			<a href="javascript:void(0)"></a>
		</div>
		<div class="ibox-content ibox-con">
			<%@include file="/jsp/common_yw_include.jsp"%>
		</div>
		<%@include file="/web/fengKongShenHe/yewuGototown1.jsp"%>

		<div class="business-manwife">车辆信息</div>
		<div class="tche-padding tancQa">
			<table cellpadding="0" cellspacing="0" border="0" class="infor-table"
				id="used-car">
				<tr>
					<td align="right"><label class="control-label np">车辆性质：</label></td>
					<td>
						<mytag:selectTag id="carType" name="carType" others="class='select-control' required='required' disabled='disabled'" map="${carType}" selected="${ywBusinessCar.carType }" />
					</td>
					<td align="right" style="display: none;">
						<label class="control-label np">启用日期：</label>
					</td>
					<td style="display: none;">
						<input id="startDate" name="startDate" readonly="readonly" type="text" class="select-control" value='<fmt:formatDate value="${ywBusinessCar.startDate }" pattern="yyyy-MM-dd"/>' />
					</td>
				</tr>
			</table>
		</div>
		<!-- 车贷信息 -->
		<%@include file="/web/fengKongShenHe/CarLoanGototown1.jsp"%>
		
		
		<form class="form-horizontal buyinfor-form" id="commentForm">
			<div class="business-manwife">垫款调整信息</div>
			<div class="tche-padding">
				<table cellpadding="0" cellspacing="0" border="0"
					class="thead-tabletz">
					<thead class="thead-a">
						<tr>
							<th></th>
							<th>原值</th>
							<th>新值</th>
							<th>调整值</th>
						</tr>
					</thead>
					<tbody class="tbody-a">
						<tr>
							<td>签约贷款额</td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="signLoanAmountOld" name="signLoanAmountOld"
								value="${cwRemitAdjustbSub.signLoanAmountOld}" /></td>
							<td><input onkeyup="counta();" class="tbody-control" readonly="readonly"
								type="number" id="signLoanAmountNew" name="signLoanAmountNew" value="${cwRemitAdjustbSub.signLoanAmountNew}" /></td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="signLoanAmountAdjust"
								name="signLoanAmountAdjust" value="${signLoanAmountAdjust}"/></td>
						</tr>
						<tr>
							<td>实际贷款额</td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="loanAmountOld" name="loanAmountOld"
								value="${cwRemitAdjustbSub.loanAmountOld}" /></td>
							<td><input onkeyup="countb();" class="tbody-control" readonly="readonly"
								type="number" id="loanAmountNew" name="loanAmountNew" value="${cwRemitAdjustbSub.loanAmountNew}" /></td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="loanAmountAdjust" name="loanAmountAdjust" value="${loanAmountAdjust}"/></td>
						</tr>
						<tr>
							<td>经销商返利</td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="rebateDealerOld" name="rebateDealerOld"
								value="${ywFees.rebateDealer}" /></td>
							<td><input onkeyup="countc();" class="tbody-control"
								type="number" id="rebateDealerNew" name="rebateDealerNew"  value="${cwRemitAdjustbSub.rebateDealerNew}" readonly="readonly"/></td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="rebateDealerAdjust" name="rebateDealerAdjust" value="${rebateDealerAdjust}"/></td>
						</tr>
						<tr>
							<td>分公司展业费</td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="rebateProvinceOld" name="rebateProvinceOld"
								value="${ywFees.rebateProvince}" /></td>
							<td><input onkeyup="countd();" class="tbody-control"
								type="number" id="rebateProvinceNew" name="rebateProvinceNew" value="${cwRemitAdjustbSub.rebateProvinceNew}" readonly="readonly"/></td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="rebateProvinceAdjust"
								name="rebateProvinceAdjust" value="${rebateProvinceAdjust}"/></td>
						</tr>
						<tr>
							<td>区域&业务员展业费</td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="rebateAreaOld" name="rebateAreaOld"
								value="${ywFees.rebateArea}" /></td>
							<td><input onkeyup="counte();" class="tbody-control"
								type="number" id="rebateAreaNew" name="rebateAreaNew" value="${cwRemitAdjustbSub.rebateAreaNew}" readonly="readonly"/></td>
							<td><input class="tbody-control" readonly="readonly"
								type="number" id="rebateAreaAdjust" name="rebateAreaAdjust" value="${rebateAreaAdjust}"/></td>
						</tr>
					</tbody>
				</table>
			</div>
		</form>
		
		
		
		<!-- 引入共有的页面 -->
		<div id="outersp" class="clear-both">
			<div id="contentmy">
				<div class="ul-style" style="display: block;">
					<form class="form-horizontal business-form" id="commentForm">
						<div class="business-padding">
							<div id="auditPre" name="auditPre" style="display: none;">
								<ul class="myul">
									<li class="myul-lia np">省公司预审详情：</li>
									<li class="myul-lib"><textarea id="pre_audit_detail" name="pre_audit_detail" rows="3" cols="" class="textarea-control"></textarea></li>
								</ul>
								<ul class="myul">
									<li class="myul-lia np">省公司预审批注：</li>
									<li class="myul-lib"><textarea id="pre_audit_postil" name="pre_audit_postil" rows="3" cols="" class="textarea-control"></textarea></li>
								</ul>
								<ul class="myul">
									<li class="myul-lia np">&nbsp;</li>
									<li class="myul-lib">
										<button type="button" class="btn dpbtn_green " onclick="approval('auditPre');">保存预审</button>
										<span class="style-red">&nbsp;&nbsp;&nbsp;注：保存后请解锁退出！</span>
									</li>
								</ul>
							</div>
							<ul class="myul">
								<li class="myul-lia np">审核详情：</li>
								<li class="myul-lib">
									<textarea id="audit_detail" name="audit_detail" rows="3" cols="" class="textarea-control"></textarea>
								</li>
							</ul>
							<ul class="myul">
								<li class="myul-lia np">审核批注：</li>
								<li class="myul-lib">
									<div class="ibox-content no-padding">
										<div class="summernote2" id="audit_postil" name="audit_postil"></div>
									</div>
								</li>
							</ul>
							<ul class="myul">
								<li class="myul-lia np">&nbsp;</li>
								<li class="myul-lib">
									<button type="button" class="btn dpbtn_green " onclick="updateAuditDetail();">保存审核批注</button>
									<span style="color: #F05050;font-size: 14px;" id="gpsPreservationSpan">&nbsp;(该信息需要单独保存)</span>
								</li>
							</ul>
							<div id="jiaZGPS" name="jiaZGPS">
								<ul class="myul">
									<li class="myul-lia np">加装GPS：</li>
									<li class="myul-lic"><input class="form-control" type="number" id="addGps_value_extras" name="addGps_value_extras" /></li>
									<li class="myul-lia np">征信押金：</li>
									<li class="myul-lic"><input class="form-control" type="number" id="addGeposit_value_extras" name="addGeposit_value_extras" /></li>
								</ul>
								<ul class="myul">
									<li class="myul-lia np">延迟垫款：</li>
									<li class="myul-lic" style="width: 360px;">
										<label> 
											<input type="checkbox" id="box_order" name="box_order" />垫款在银行放款后
										</label>
									</li>
								</ul>
							</div>
							<ul class="myul">
								<li class="myul-lia np">&nbsp;</li>
								<li class="myul-lib">
									<button type="button" class="btn dpbtn_green " onclick="gpsOk();" id="gpsPreservation">保存附加条件</button>
								</li>
							</ul>
							<ul class="myul">
								<li class="myul-lia np">&nbsp</li>
								<li>
									<button type="button" class="btn dpbtn_green" onclick="approval('pass');" id="pass" style="display: none;">过审</button>
									<button type="button" class="btn dpbtn_blue" onclick="eventFail();" id="fail" style="display: none;">不过审</button>
									<button type="button" class="btn dpbtn_red"  onclick="approval('editback');" id="editback" style="display: none;">退回修改</button> 
									<button type="button" class="btn dpbtn_green" onclick="tuihui();" id="auditback" style="display: none;">退回审核</button> 
									<button type="button" class="btn dpbtn_green" onclick="approval('lesspass');" id="lesspass" style="display: none;">欠资料过审</button> 
									<button type="button" class="btn dpbtn_blue" onclick="reportFormZpp();" id="reportForm" name="reportForm" style="display: none;">查看按揭日报表</button>
								</li>
							</ul>
						</div>
					</form>
				</div>
				<div class="ul-style">
					<form class="form-horizontal business-form">
						<div class="business-padding" id="historical_approval" name="historical_approval">&nbsp;</div>
					</form>
				</div>
			</div>
		</div>
		<div style="display: none; width: 180px;margin:0 auto;" id="falseId">
			<br/>
			<div style="font-weight: 500;">请选择退单原因：</div>
			<br/>
			<ul>
				<li><label><input type="radio" name="falseRadio" value="01"/>虚假资料</label></li>
				<br/>
				<li><label><input type="radio" name="falseRadio" value="02"/>资质不足</label></li>
				<br/>
				<li><label><input type="radio" name="falseRadio" value="99"/>其他</label><input class="form-control" type="text" id="reason_audit_false_name" name="reason_audit_false_name" placeholder="请输入其他" maxlength="125"/></li>
			</ul>
			<br/>
			<button type="button" class="btn dpbtn_blue " onclick="approval('fail');">不过审</button>
		</div>
		
		
		
	</div>
	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>
	<!-- layerDate plugin javascript -->
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
	<!-- 验证  -->
	<%@include file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<!-- summernote -->
	<%@include file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>
	
	<!-- 
 	    作者：程立勇
 	   描述：js脚本
 	 -->
	<script type="text/javascript">
	
	 	$(function(){
	 		if('${ywBusinessCar.carType}' == "01")
	 		{
	 			$('.usedCar').hide();
	 		}
	 	});
	 	
	 	$(function(){
 		    $('#audit_postil').summernote({
	            lang: 'zh-CN',
	            toolbar:[
					['style', ['bold', 'italic', 'underline', 'clear']],
					['color', ['color']]
	            ]
	        });
	 		initData();
	 		
	 		if(${ywBusinessLoan.loanType} == "04")
	 		{
	 			$('.d6').hide();
	 		}
	 	});
	 	
	 	
	 	//初始化加载
	 	var initData = function()
	 	{
	 		var busiId = '${busiId}';
	 		var modeId = '${modeId}';
	 		
	 		$.dpAjax({
		   		url:'${basePath}/FengKongShenHeController/diepuFengKongShenHeAuditListV001',
		   		data:{
		   			"busiId":busiId,
		   			"modeId":modeId
		   		},
				success: function(datas)
				{
			 	  if(datas.flag == "100100")
			 	  {
			 		  var fkAuditList = datas.fkAuditList;
			 		  if(fkAuditList)
			 		  {
			 			  var audit_detail = fkAuditList.auditDetail;
				 		  var audit_postil =  fkAuditList.auditPostil;
				 		  $('#audit_detail').text(audit_detail);
				 		  $('#audit_postil').code(audit_postil);
			 		  }
			 		  
			 		  var fkPreAuditInfo = datas.fkPreAuditInfo;
			 		  if(fkPreAuditInfo)
			 		  {
			 			  $('#pre_audit_detail').val(fkPreAuditInfo.preAuditDetail);
			 			  $('#pre_audit_postil').val(fkPreAuditInfo.preAuditPostil);
			 		  }
			 		  
			 		  var otherAuditInfo = datas.otherAuditInfo;
			 		  if(otherAuditInfo)
			 		  {
			 			  var content = '';
			 			  var d = otherAuditInfo;
				 		  for(var i=0;i<d.length;i++)
				 		  {
				 			  var audit_name = d[i].auditName
				 			  var org_name = d[i].orgName
				 			  var creator_name = d[i].creatorName;
				 			  var created = d[i].created;
				 			  var audit_postil = d[i].auditPostil;
			 			      content += '<ul class="course-table">'
				 			  			  + '<li  class="rgb-color">'+audit_name+'</li>'
				 			  			  + '<li class="course-tablelib">'
				 			  			  	+ '<p class="course-time">'+org_name+' &nbsp; '+creator_name+' &nbsp;'+created+'</p>'
				 			  			  	+ audit_postil
				 			  			  + '</li>'
				 			  		  + '</ul>';
				 		  }
				 		  $('#historical_approval').html(content);
			 		  }
			 		  
			 		  //加装GPS  加收押金
			 		  var d = datas.gpsResult;
			 		  if(d && d.length > 0)
			 		  {
			 			 for(var i=0;i<d.length;i++)
			 			  {
			 				  var b = d[i];
			 				  var type_extras = b.typeExtras;
			 				  var code_extras = b.codeExtras;
			 				  var value_extras = b.valueExtras
			 				  if(code_extras == "AddGps" && type_extras == "Audit")
			 				  {
			 					  $('#addGps_value_extras').val(value_extras);
			 				  }
			 				  else if(code_extras == "AddGeposit" && type_extras == "Audit")
			 				  {
			 					 $('#addGeposit_value_extras').val(value_extras);
			 				  }
			 				  else if(code_extras == "IsSpecialOrder" && type_extras == "Audit")
			 				  {
			 					  if(value_extras == "1")
			 					  {
			 						 document.getElementById("box_order").checked = true;
			 					  }
			 				  }
			 			  }
			 		  }
			 		  
			 		  //是否显示GPS保存按钮
			 		  var gpsPreservation = datas.gpsPreservation;
			 		  if(gpsPreservation)
			 		  {
			 			  if(gpsPreservation == "no")
			 			  {
			 				  $('#gpsPreservation').hide();
			 			  }
			 		  }
			 		  
			 		  //GPS是否禁用只能查看
			 		  var gpsDisable = datas.gpsDisable;
			 		  if(gpsDisable)
			 		  {
			 			  if(gpsDisable == "no")
			 			  {
			 				 $('#addGps_value_extras').attr("readonly","readonly");
			 				 $('#addGeposit_value_extras').attr("readonly","readonly");
			 				 $('#box_order').attr("disabled","disabled");
			 			  }
			 		  }
			 		  
			 		  //按钮权限显示隐藏
			 		  var eventPasses = datas.eventPasses;
			 		  if(eventPasses && eventPasses.length > 0)
			 		  {
			 			  for(var i=0;i<eventPasses.length;i++)
			 			  {
			 				  if(eventPasses[i].event == "pass")
			 				  {
			 					  $('#pass').show();
			 				  }
			 				  else if(eventPasses[i].event == "fail")
			 				  {
			 					  $('#fail').show();
			 				  }
			 				  else if(eventPasses[i].event == "editback")
			 				  {
			 					  $('#editback').show();
			 				  }
			 				  else if(eventPasses[i].event == "auditback")
			 				  {
			 					  $('#auditback').show();
			 				  }
			 				  else if(eventPasses[i].event == "lesspass")
			 				  {
			 					  $('#lesspass').show();
			 				  }
			 				  else if(eventPasses[i].event == "auditPre")
			 				  {
			 					  $('#auditPre').show();
			 				  }
			 				  else if(eventPasses[i].event == "auditReport")
			 				  {
			 					  $('#reportForm').show();
			 				  }
			 			  }
			 		  }
			 		  
			 		  //欠资料过审禁用
			 		  var ywBusiness = datas.ywBusiness;
			 		  if(ywBusiness)
			 		  {
			 			  if(ywBusiness.lessInformationStatus == "10")
			 			  {
			 				$('#pass').attr("disabled","disabled");
			 			  }
			 			  //else if(ywBusiness.lessInformationStatus == "20" || ywBusiness.lessInformationStatus == "30")
			 			  //{
			 			  //   $('#lesspass').attr("disabled","disabled");
			 			  //}
			 		  }
			 		  
			 		  
			 		  //隐藏GPS等信息
			 		  var diankuanTZ = datas.diankuanTZ;
			 		  if(diankuanTZ)
			 		  {
			 			 if(diankuanTZ == "no")
			 			 {
			 				 $('#jiaZGPS').hide();
			 			 }
			 		  }
			 		  return;
				  }
				  layer.msg(datas.message, {icon: 2});
				}
		   	});
	 	}
	 	
	 	//修改批注信息
	 	var updateAuditDetail = function()
	 	{
	 		var busiId = $('#busiId').val();
	 		var modeId = $('#modeId').val();
	 		var audit_detail = $('#audit_detail').val();
	 		var audit_postil = $('#audit_postil').code();
	 		
	 		//询问框
	 		layer.confirm('确认执行本次操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
	 		  btn: ['确定','取消'] //按钮
	 		}, function(){
	 			layer.closeAll();
	 			$.dpAjax({
		 			url:'${basePath}/FengKongShenHeController/insertOtherAudit',
		 			data:{
		 				"modeId":modeId,
		 				"busiId":busiId,
		 				"auditDetail":audit_detail,
		 				"auditPostil":audit_postil,
		 			},
		 			success: function(datas)
		 			{
		 				  if(datas.flag == "100100")
		 				  {
		 					  layer.msg("批注更新成功！", {icon: 6});
		 					  return;
		 				  }
		 				  layer.msg(datas.message, {icon: 5});
		 		     }
		 		});
	 		}, function(){
	 			layer.msg('已取消本次操作！', {icon: 6});
	 		});
	 	}
	 	
	 	
	 	//审批
		  var approval = function(event)
		  {
			  var replaceId = $('#replaceId').val();
	 		  var busiId = $('#busiId').val();
	 		  var modeId = $('#modeId').val();
	 		  var audit_detail = $('#audit_detail').val();
	 		  var audit_postil = $('#audit_postil').code();
	 		  var org_code = '${current_user_key.orgId}';
	 		  var org_name = '${current_user_key.orgName}';
	 		  var auditRemarks = $('#auditRemarks').val();
		 	  if(auditRemarks == "")
		 	  {
		 		 layer.msg('备注不能为空！', {icon: 5});
		 		 return false;
		 	  } 
			  if(event == "auditback")
			  {
					var rowData = jQuery('#table_list_2').jqGrid('getGridParam','selarrrow');  
			    	if(rowData.length < 1)
			    	{  
			    		layer.msg("请选择要退回菜单！", {icon: 5});
						return;
			    	}
			    	
			    	if(rowData.length > 1)
			    	{
			    		layer.msg("只能选择一列菜单退回！", {icon: 5});
						return;
			    	}
			    	
			    	modeId +="@@@"+jQuery('#table_list_2').jqGrid('getCell',rowData[0],'modeId'); 
			  }
			 
		    	
			 var reason_audit_false = "";
			 var reason_audit_false_name = "";
			 
			 if(event == "fail")
			 {
		 		var falseRadio = document.getElementsByName("falseRadio");
		 		for(var i=0;i<falseRadio.length;i++)
		 		{
		 			if(falseRadio[i].checked)
					{
		 				reason_audit_false = falseRadio[i].value;
						break;
					}
		 		}
		 		if(!reason_audit_false)
		 		{
		 			layer.msg('请选择退回的原因！', {icon: 6});
		 			return;
		 		}
		 		
		 		reason_audit_false_name = $('#reason_audit_false_name').val();
		 		
		 		if(reason_audit_false && reason_audit_false == "99" && reason_audit_false_name == "")
		 		{
		 			layer.msg('请输入其他退回原因！', {icon: 6});
		 			return;
		 		}	
		 		
		 		
		 		
		 		if(reason_audit_false == "01")
		 		{
		 			reason_audit_false_name = "虚假资料";
		 		}
		 		else if(reason_audit_false == "02")
		 		{
		 			reason_audit_false_name = "资质不足";
		 		}
			 }
			 
			 if(event == "auditPre")
			 {
				 audit_detail = $('#pre_audit_detail').val();
		 		 audit_postil = $('#pre_audit_postil').val();
			 }
	 		 
	 		//询问框
	 		layer.confirm('确认执行本次操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
	 		  btn: ['确定','取消'] //按钮
	 		}, function(){
	 			layer.closeAll();
	 			$.dpAjax({
		 			url:'${basePath}/FengKongShenHeController/diepuFengKongShenHeV001',
		 			data:{
		 				"event":event,
		 				"id":replaceId,
		 				"busiId":busiId,
		 				"modeId":modeId,
		 				"auditDetail":audit_detail,
		 				"auditPostil":audit_postil,
		 				"orgCode":org_code,
		 				"orgName":org_name,
		 				"remarks":auditRemarks,
		 				"reasonAuditFalse":reason_audit_false,
		 				"reasonAuditFalseName":reason_audit_false_name
		 			},
		 			success: function(datas)
		 			{
		 				  if(datas.flag == "100100")
		 				  {
		 					  layer.msg('审核执行成功！', {icon: 6});
		 					  setTimeout(function(){
		 						 window.location.href = "${basePath}/web/fengKongShenHe/fkshApprovalList.jsp?modeId="+$('#modeId').val();
		 					  },1000);
		 					  return;
		 				  }
		 				  layer.msg(datas.message, {icon: 5});
		 		     }
		 		});
	 			
	 		}, function(){
	 			layer.msg('已取消本次操作！', {icon: 6});
	 		});
		  }
	 	
	</script>
</body>
</html>
